package anli;
import java.util.Scanner;
public class practice {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //第一件商品信息
        System.out.print("请输入第一件商品的名称：");
        String commodityName1 = scan.next();
        System.out.print("请输入第一件商品的数量：");
        int productQuantity1 = scan.nextInt();
        System.out.print("请输入第一件商品的单价：");
        double commodityPrice1 = scan.nextDouble();
        System.out.println("第一件商品录入成功！");
        //第二件商品信息
        System.out.print("请输入第二件商品的名称：");
        String commodityName2 = scan.next();
        System.out.print("请输入第二件商品的数量：");
        int productQuantity2 = scan.nextInt();
        System.out.print("请输入第二件商品的单价：");
        double commodityPrice2 = scan.nextDouble();
        System.out.println("第二件商品录入成功！");
        //第三件商品信息
        System.out.print("请输入第三件商品的名称：");
        String commodityName3 = scan.next();
        System.out.print("请输入第三件商品的数量：");
        int productQuantity3 = scan.nextInt();
        System.out.print("请输入第三件商品的单价：");
        double commodityPrice3 = scan.nextDouble();
        System.out.println("第三件商品录入成功！");
        //计算总金额
        double totalAmount1 = productQuantity1 * commodityPrice1;
        double totalAmount2 = productQuantity2 * commodityPrice2;
        double totalAmount3 = productQuantity3 * commodityPrice3;
        //表单内容
        System.out.println("***欢迎来到旺旺超市***");
        System.out.println("-------------------");
        System.out.println("商品名称        数量       单价        金额");
        System.out.println(commodityName1 + "   " + productQuantity1 + "    " + commodityPrice1 + "     " + totalAmount1);
        System.out.println(commodityName2 + "   " + productQuantity2 + "    " + commodityPrice2 + "     " + totalAmount2);
        System.out.println(commodityName3 + "   " + productQuantity3 + "    " + commodityPrice3 + "     " + totalAmount3);
        System.out.println("-------------------");
        //申明需要变量并赋值
        int totalQuantity = productQuantity1 + productQuantity2 + productQuantity3;//总数量
        double totalAmount = totalAmount1 + totalAmount2 + totalAmount3;//总金额
        double Discount = totalAmount >= 100 || totalQuantity >= 10 ? totalAmount * 0.5 : totalAmount;//打折后的价格
        //结算账单
        System.out.println("总数量：" + totalQuantity);
        System.out.println("总金额：" + totalAmount);
        System.out.println("已优惠金额：" + (totalAmount - Discount));
        System.out.println("实付金额：" + Discount);
    }
}
